package com.wili.c.asm;
import java.io.File;
import java.io.Serializable;
/**
 * 
 * @author weila 2021年3月8日
 */
public class FieldItem implements Serializable {
	private static final long serialVersionUID = 1L;

	public Class<?> cls;

	public String field;
	public String toString() {
		return cls.getSimpleName() + "." + field;
	}

	/**
	 * in class $inCls, find field $cls.field at line:$lineNo
	 */
	public FieldItem(Class<?> cls, String field) {
		this.cls = cls;
		this.field = field;
	}
}
class PutFieldItem implements Comparable<PutFieldItem>, Serializable {
	private static final long serialVersionUID = 1L;

	public File classFile;

	public Class<?> inCls, cls;

	public String field;

	public int lineNo;
	public boolean equals(Object obj) {
		if (!(obj instanceof PutFieldItem))
			return false;
		PutFieldItem ret = (PutFieldItem) obj;
		if (inCls.equals(ret.inCls)) {
			if (cls.equals(ret.cls)) {
				if (field.equals(ret.field))
					return true;
			}
		}
		return false;
	}

	public String toString() {
		String st = inCls.getSimpleName();
		if (st.isEmpty())
			st = inCls.getName();//eg. anonymouse class.
		return st + "/" + cls.getSimpleName() + "." + field + "@" + lineNo;
	}

	/**
	 * in class $inCls, find field $cls.field at line:$lineNo
	 */
	public PutFieldItem(Class<?> inCls, Class<?> cls, String field, int lineNo) {
		this.inCls = inCls;
		this.cls = cls;
		this.field = field;
		this.lineNo = lineNo;
	}

	@Override
	public int compareTo(PutFieldItem o) {
		return this.lineNo - o.lineNo;
	}
}